package com.ymatou.iapi.userservice.testcase;

import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.login.parameter.AliUserRequestDtoBean;
import com.ymatou.iapi.login.parameter.SinaWeiBoUserRequestDtoBean;
import com.ymatou.iapi.login.parameter.WeiXinUserRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.*;
import com.ymatou.iapi.userservice.service.*;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;
import com.ymttest.utils.constant.ThirdPartyType;
/**
*是否绑定手机
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_CheckThirdPartyUserIsRealNeedBindMobileDto{
	private static CheckThirdPartyUserIsRealNeedBindMobileDtoBean checkthirdpartyuserisrealneedbindmobiledtoBean;
	private static CheckThirdPartyUserIsRealNeedBindMobileDtoCall checkthirdpartyuserisrealneedbindmobiledtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("是否绑定手机");
	}

	@Before
	public void caseUp() {
		checkthirdpartyuserisrealneedbindmobiledtoBean=new CheckThirdPartyUserIsRealNeedBindMobileDtoBean();
		checkthirdpartyuserisrealneedbindmobiledtoCall=new CheckThirdPartyUserIsRealNeedBindMobileDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(checkthirdpartyuserisrealneedbindmobiledtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_001() {
		Logger.start(true,"ali绑定手机查询Result:no,成功");
		try {
			AliUserRequestDtoBean aliUserRequestDtoBean=JUserCallService.initAliUserRequestDtoBean();
			aliUserRequestDtoBean.setMobile(TestDataManager.getPhoneNum());
			JUserCallService.aliUserRequestDto(aliUserRequestDtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUserRequestDtoBean.getSAliUserId());
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_002() {
		Logger.start(true,"ali不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_003() {
		Logger.start(true,"不输入ThirdPartyId，失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals("100", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_004() {
		Logger.start(true,"不输入ThirdPartyType,失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
//			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals("100", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	@Ignore
	//暂不考虑
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_005() {
		Logger.start(true,"输入错误ThirdPartyType,失败");
		try {
			String aliUser = "ali_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI+1);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR500, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_006() {
		Logger.start(true,"weixin绑定手机查询Result:no,成功");
		try {
			WeiXinUserRequestDtoBean bean=JUserCallService.initWeiXinUserRequestDtoBean();
			bean.setMobile(TestDataManager.getPhoneNum());
			JUserCallService.weiXinUserRequestDto(bean);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(bean.getUnionId());
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIXIN);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_007() {
		Logger.start(true,"weixin不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "wx_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIXIN);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_008() {
		Logger.start(true,"weibo绑定手机查询Result:no,成功");
		try {
			SinaWeiBoUserRequestDtoBean bean=JUserCallService.initSinaWeiBoUserRequestDtoBean();
			bean.setMobile(TestDataManager.getPhoneNum());
			JUserCallService.sinaWeiBoUserRequestDto(bean);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(bean.getSWeiboUserId());
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.WEIBO);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();
			Logger.verifyEquals(ECode.SUCCESS, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("no", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_CheckThirdPartyUserIsRealNeedBindMobileDto_009() {
		Logger.start(true,"weibo不绑定手机查询Result:yes,成功");
		try {
			String aliUser = "wb_"+TestDataManager.getRandomNum(10);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyId(aliUser);
			checkthirdpartyuserisrealneedbindmobiledtoBean.setThirdPartyType(ThirdPartyType.ALI);
			checkthirdpartyuserisrealneedbindmobiledtoCall.setData(checkthirdpartyuserisrealneedbindmobiledtoBean);
			checkthirdpartyuserisrealneedbindmobiledtoCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, checkthirdpartyuserisrealneedbindmobiledtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("yes", checkthirdpartyuserisrealneedbindmobiledtoCall.getString("Result"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}